<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> 子传父</title>
    <style>
    </style>
</head>
<body>
    <div id="app" >
        <zi :num="num" @pigtext='handle'></zi>
    </div>

    <script src="../Day1/js/vue.js"></script>

    <script>
        
        Vue.component('zi',{
            props:['num'],
            data:function(){
                return{
                    shu:''
                }
            },
            template:`<div>
                <h1>{{num}}</h1>
                <input type="text" v-model.number='shu'>
                <button @click='jia'>+</button>
                </div>`,
                methods:{
                    jia(){
                        this.$emit('pigtext',this.shu)
                    }
                }
        })
        //父
        var vm=new Vue({
            el:'#app',
            data:{
               num:5,
            },
            components:{
            },methods:{
                handle(v){
                    this.num+=v;
                }
            }
        });
    </script>
</body>
</html>